package com.janedler.jtoast;

import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import java.util.concurrent.LinkedBlockingDeque;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btnOpen = (Button) findViewById(R.id.btn_open);
        Button btnClose = (Button) findViewById(R.id.btn_close);
		//
        btnOpen.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                CFPToast.makeText(getApplicationContext(), "hello world", 3000).show();
                CFPToast.makeText(getApplicationContext(), "hello world1", 3001).show();
                CFPToast.makeText(getApplicationContext(), "hello world2", 3002).show();
                CFPToast.makeText(getApplicationContext(), "hello world3", 3003).show();
                CFPToast.makeText(getApplicationContext(), "hello world4", 3004).show();
                CFPToast.makeText(getApplicationContext(), "hello world5", 3005).show();
                CFPToast.makeText(getApplicationContext(), "hello world6", 3006).show();
            }
        });
        btnClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //CFPToast.makeText(getApplicationContext(), "点击我" + System.currentTimeMillis(), CFPToast.LENGTH_SHORT).show();
                //defineToast();
                defineJToast();
//                test();
            }
        });
    }



    private void defineNativeToast(){

        LayoutInflater inflater = LayoutInflater.from(this);
        View view = inflater.inflate(R.layout.define_toast_layout, null);
        TextView tv = (TextView) view.findViewById(R.id.message);
        tv.setText("我是自定义文本控件");
        Toast toast = new Toast(this);
        toast.setGravity(Gravity.BOTTOM, 0, 0);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.setView(view);
        toast.show();

    }

    int i = 0;
    private void defineJToast(){

        LayoutInflater inflater = LayoutInflater.from(this);
        View view = inflater.inflate(R.layout.define_toast_layout, null);
        TextView tv = (TextView) view.findViewById(R.id.message);
        tv.setText("我是自定义文本控件>>"+(i++));
        CFPToast toast = new CFPToast(this);
        toast.setGravity(Gravity.BOTTOM, 0, 0);
        toast.setDuration(CFPToast.LENGTH_LONG);
        toast.setView(view);
        toast.show();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
